//反转链表

/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     struct ListNode *next;
 * };
 */

struct ListNode* reverseList(struct ListNode* head)
{
	struct ListNode *pre = NULL, *cur = head, *save;
	while (cur) {
		save = cur->next;
		cur->next = pre;

		pre = cur;
		cur = save;
	}
	return pre;
}